#ifndef __davinci_timer_h__
#define __davinci_timer_h__
#include "types.h"
struct davinci_timer {
	__u32	pid12;
	__u32	emumgt;
	__u32	na1;
	__u32	na2;
	__u32	tim12;
	__u32	tim34;
	__u32	prd12;
	__u32	prd34;
	__u32	tcr;
	__u32	tgcr;
	__u32	wdtcr;
};


#define DAVINCI_TIMER_PID12 (int)(&((struct davinci_timer*)0)->pid12)
#define DAVINCI_TIMER_EMUMGT (int)(&((struct davinci_timer*)0)->emumgt)
#define DAVINCI_TIMER_NA1 (int)(&((struct davinci_timer*)0)->na1)
#define DAVINCI_TIMER_NA2 (int)(&((struct davinci_timer*)0)->na2)
#define DAVINCI_TIMER_TIM12 (int)(&((struct davinci_timer*)0)->tim12)
#define DAVINCI_TIMER_TIM34 (int)(&((struct davinci_timer*)0)->tim34)
#define DAVINCI_TIMER_PRD12 (int)(&((struct davinci_timer*)0)->prd12)
#define DAVINCI_TIMER_PRD34 (int)(&((struct davinci_timer*)0)->prd34)
#define DAVINCI_TIMER_TCR (int)(&((struct davinci_timer*)0)->tcr)
#define DAVINCI_TIMER_TGCR (int)(&((struct davinci_timer*)0)->tgcr)

// copied from addressmap.h to avoid including 
#define ADDR_RANGE_READ  1            // Bus read
#define ADDR_RANGE_WRITE 2           // Bus write
#define ADDR_RANGE_DEL   3           // delete an address range



#define DAVINCI_TIMER_ADDR_SIZE 0x400 //sizeof(struct davinci_timer)

int davinci_timer_init();
void davinci_timer_do_clock();

void davinci_timer_handler(
	  void *lpContext,
	  int op, 
	  unsigned int dwAddress,           // start dwAddress on 32bit bus
	  char *pszBuff,           // optional 
	  unsigned int nBytes );            // in or out buffer
#endif //__davinci_timer_h__